//
//  QTEvaTableViewCell.m
//  qdqts
//
//  Created by jonn on 14-7-1.
//  Copyright (c) 2014年 seas.cheng. All rights reserved.
//

#import "QTEvaTableViewCell.h"

@implementation QTEvaTableViewCell

- (void)awakeFromNib
{
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(CGFloat)contentHeight{
    NSString *content    = _tmpForcontent;
    //NSLog(@"the content of words:%@",_tmpForcontent);
    // 1000仅仅是个约数，只要保证content能显示完整就行
    // 在IB中要把UILabel的换行类型设置为UILineBreakModeWordWrap
    // IB中一定要将UILabel的Layout属性的Lines设置为0，以保证宽度自适应
//    CGSize  contentSize  = [content sizeWithFont:baseFone constrainedToSize:CGSizeMake(280, 10000) lineBreakMode:UILineBreakModeWordWrap];
    CGSize  contentSize=[self sizeForLabel:13 withContent:content];
    NSLog(@"contentHeight:%f",contentSize.height);
    return contentSize.height+50;
}
-(void)setContentForLabel:(NSString *)content{
    _tmpForcontent=content;
     CGSize  contentSize=[self sizeForLabel:13 withContent:content];
    CGSize reassignLabel=_contentLabel.frame.size;
    reassignLabel.height=contentSize.height;
    _contentLabel.frame= CGRectMake(_contentLabel.frame.origin.x, _contentLabel.frame.origin.y, reassignLabel.width, contentSize.height);
    UILabel * label=[[UILabel alloc]initWithFrame:_contentLabel.frame];
    [label setLineBreakMode:NSLineBreakByWordWrapping];
    [label setNumberOfLines:0];
    label.text=content;
    [[self contentView] addSubview:label];
    NSLog(@"ContentForLabel:%f",contentSize.height);
}

-(CGSize)sizeForLabel:(CGFloat)font withContent:(NSString*)forContent
{
    NSDictionary * attribute=@{NSFontAttributeName:[UIFont systemFontOfSize:font]};
    CGSize size= [forContent boundingRectWithSize:CGSizeMake(188,0)  options:NSStringDrawingTruncatesLastVisibleLine | NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading  attributes:attribute context:nil].size;
    return  size;
}

@end

